# Contributor: Peter Bui <pnutzh4x0r@gmail.com>
# Maintainer: Sheila Aman <sheila@vulpine.house>
pkgname=bitlbee
pkgver=3.6
pkgrel=3
pkgdesc="An IRC to other chat networks gateway"
url="https://www.bitlbee.org/"
arch="all"
options="!check" # no test suite
license="GPL-2.0-or-later"
makedepends="python3 glib-dev gnutls-dev libotr-dev"
subpackages="$pkgname-dev $pkgname-doc $pkgname-otr $pkgname-openrc"
install="$pkgname.pre-install"
pkgusers="bitlbee"
pkggroups="bitlbee"
source="http://get.bitlbee.org/src/bitlbee-$pkgver.tar.gz
	$pkgname.initd
	$pkgname.confd
	bitlbee.conf
	"

build() {
	PYTHON=python3 \
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--otr=plugin \
		--prefix=/usr \
		--etcdir=/etc/bitlbee \
		--ssl=gnutls # https://bugs.bitlbee.org/ticket/886
	make
}

package() {
	make DESTDIR="$pkgdir" install install-etc install-dev
	mv "$pkgdir"/usr/sbin "$pkgdir"/usr/bin

	install -m755 -D "$srcdir"/$pkgname.initd \
		"$pkgdir"/etc/init.d/$pkgname
	install -m644 -D "$srcdir"/$pkgname.confd \
		"$pkgdir"/etc/conf.d/$pkgname

	mkdir -p "$pkgdir"/var/lib/bitlbee
	chown bitlbee:bitlbee "$pkgdir"/var/lib/bitlbee

	install -m644 -D "$srcdir"/bitlbee.conf \
		"$pkgdir"/etc/bitlbee/bitlbee.conf
}

otr() {
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/bitlbee "$subpkgdir"/usr/lib
}

sha512sums="
ccbf0f23e228de2de147241f36f59744b2256cba958e2fabfba0cfa60935e55bbb7d7e20fffa54da9a345e55ffa9ca82cb62e9b99dc738ba35c6e268c6561a8d  bitlbee-3.6.tar.gz
5d79b8c827eba2c11c0d2135ee94c01322afcd841fb47456311322d5fc7a7d671cac7b9eee0adee7f3f10612a4ebb9ebfc8600a428a1e0c54034f730310f92c1  bitlbee.initd
0253a7758588b276217d74ed43f7772906a1d5e6a58ffe532b8495ab5509e88ea32f77887b9a23e1da5ceeeecaff83e5ef8d6a08e9041a049f4f78f4379fd053  bitlbee.confd
325d5d37dddaaa651de5615038cf73422b6f81e590df4bb2917aa2bc470247ad6334f43f309e667f063e6c73d3f71e1132bf61552ec84c26f5bd5369cf01ebc1  bitlbee.conf
"
